{% extends "base.html" %}

{% block title %}词典管理工具{% endblock %}
<link href="{{ url_for('static',filename='tableStyle.css') }}" rel="stylesheet">
{% block page_content %}
    <div class="page-header">
        <h1>欢迎使用词典管理工具</h1>
    </div>
    <form method="POST">
        {{ form.csrf_token }}
        {{ form.name.label }} {{ form.name() }}
        {{ form.submit() }}
        <a href="/addNew" style="font-size: 18px;margin-left: 20px;">添加新词</a>
    </form>
    <div class="panel-body">
        {% if result %}
            <table width="70%" border="1" cellpadding="0" cellspacing="1">
                <tr>
                    <th>ID</th>
                    <th>编码</th>
                    <th>ICD编码</th>
                    <th>SNOMED编码</th>
                    <th>名称</th>
                    <th>备注</th>
                    <th>编辑</th>
                    <th>删除</th>
                </tr>
                {% for i in range(n) %}
                    <tr>
                        <td>{{ result[i].id }}</td>
                        <td>{{ result[i].code }}</td>
                        <td>{{ result[i].ICD_code }}</td>
                        <td>{{ result[i].SNO_code }}</td>
                        <td>{{ result[i].name }}</td>
                        <td>{{ result[i].description }}</td>
                        <td>
                            <a href="{{ url_for('.edit',word_id=result[i].id) }}">编辑</a>
                        </td>
                        <td>
                            {#                            <a href="{{ url_for('.delete',id=result[i].id) }}">删除</a>#}
                            <a href="javascript:delete_word{{ result[i].id }}()">删除</a>
                            <form method="POST" id="delete_word{{ result[i].id }}">
                                {{ deleteWordForm.hidden_tag() }}
                                {{ deleteWordForm.id(class="hidden", value=result[i].id) }}
                            </form>
                            <script type="text/javascript">
                                function delete_word{{ result[i].id }}() {
                                    $("#delete_word{{ result[i].id }}").submit();
                                }
                            </script>
                        </td>
                    </tr>
                {% endfor %}
            </table>
        {% else %}
            <h3>未查询到该词，数据库中可能不存在该词，你可以添加该词到数据库</h3>
        {% endif %}
    </div>
{% endblock %}
